<style type="text/css">
<!--
body {
	background-color: #DFECE0;
}
-->
</style><?php
include_once 'config.php';
class User
{
//Database connect 
public function __construct() 
{
$db = new DB_Class();
}
//Registration process 
public function register_user($name, $username, $password, $email)
{
$password = md5($password);
$sql = mysql_query("SELECT User_id from users WHERE user_name = '$username' or user_email = '$email'");
$no_rows = mysql_num_rows($sql);
if ($no_rows == 0) 
{
$result = mysql_query("INSERT INTO users(User_name, User_password, User_fullname, User_email) values ('$username', '$password','$name','$email')") or die(mysql_error());
return $result;
}
else
{
return FALSE;
}
}
// Login process
public function check_login($username, $password) 
{
$password = md5($password);
$result = mysql_query("SELECT User_id from users WHERE  User_name='$username' and User_password = '$password'");
$user_data = mysql_fetch_array($result);
$no_rows = mysql_num_rows($result);

if ($no_rows == 1) 
{
$_SESSION['login'] = true;
$_SESSION['uid'] = $user_data['User_id'];
return TRUE;
}
else
{
return FALSE;
}
}
// Getting name
public function get_fullname($uid) 
{
$result = mysql_query("SELECT User_fullname FROM users WHERE User_id = $uid");
$user_data = mysql_fetch_array($result);
echo $user_data['User_fullname'];
}
// Getting session 
public function get_session() 
{
if(isset($_SESSION['login']))
return $_SESSION['login'];
}
// Logout 
public function user_logout() 
{
$_SESSION['login'] = FALSE;
$_SESSION['uid'] = "";
session_destroy();
}

}
?>